#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
    static bool cmp(vector<int>a, vector<int>b)
    {
        return a[0] - a[1] < b[0] - b[1];
    }
    int twoCitySchedCost(vector<vector<int>>& costs)
    {
        int res = 0;
        vector<vector<int>>arr = costs;
        sort(arr.begin(), arr.end(), cmp);
        for (int i = 0; i < arr.size() / 2; i++)
            res += arr[i][0];
        for (int i = arr.size() / 2; i < arr.size(); i++)
            res += arr[i][1];
        return  res;
    }
};
int main()
{
	return 0;
}